// Winters 2010 WP

// REPLICATION
// Figure 4
// Model 1
clear
use "W2010 WP Rep Data.dta"
summarize
display c(k)
mdesc
tabmiss
codebook country
codebook year

gen loggdppc1=log(gdppc)
gen loginvest=log(invest)
gen logdebtgni=log(debtgni)
gen logpop1=log(pop)
gen loglandarea=log(landarea)
sort country year
xtset country year

// Prog Lending
reg pct_prog4 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia
mdesc pct_prog4 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia
codebook year if e(sample)
codebook country if e(sample)

// Nat Lending
reg pct_natl5 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia
mdesc pct_natl5 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia
codebook year if e(sample)
codebook country if e(sample)

// Model 2
// Prog Lending
keep if ida1==1
reg pct_prog4 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia if ida1==1
mdesc pct_prog4 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia
codebook year if e(sample)
codebook country if e(sample)

// Nat Lending
reg pct_natl5 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia if ida1==1
mdesc pct_natl5 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia
codebook year if e(sample)
codebook country if e(sample)

// Model 3
// Prog Lending
clear
use "W2010 WP Original.dta"
keep if ida1 == 0

reg pct_prog4 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia if ida1==0
codebook year if e(sample)
codebook country if e(sample)
mdesc pct_prog4 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia

// Nat Lending
reg pct_natl5 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia if ida1==0
mdesc pct_natl5 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia
codebook year if e(sample)
codebook country if e(sample)

// IMPUTATION
// Figure 4
// Model 1 and 2
clear
use "W2010 WP Imp Data.dta"
summarize

mi import flong, m(imp) id(year country) imp(africa-invest ida1-loglandarea)

sort country year
mi xtset country year

// Prog Lending
mi estimate, post: reg  pct_prog4 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia
// Nat Lending
mi estimate, post: reg pct_natl5 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia

// Model 3 and 4
// Prog Lending
mi estimate, post: reg pct_prog4 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia if ida1 == 1
// Nat Lending
mi estimate, post: reg pct_natl5 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia if ida1 == 1

// Model 5 and 6
// Prog Lending
mi estimate, post: reg pct_prog4 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia if ida1 == 0
// Nat Lending
mi estimate, post: reg pct_natl5 gmavg loggdppc1 loginvest logdebtgni imf logpop1 loglandarea africa eastasia latinam mena southasia if ida1 == 0

